package com.sicheng.蓝桥.练习题;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/1/19 21:38
 */
public class 双向排列 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();//序列长度
        int m = scanner.nextInt();//操作次数

        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = i + 1;
        }
        while (m > 0) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            if (p == 0) {
                Arrays.sort(nums, 0, q, Comparator.reverseOrder());
            } else
                Arrays.sort(nums, q - 1, n);
            m--;
        }

        for (Integer num : nums) {
            System.out.print(num + " ");
        }
    }
}
